home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / wlib11_2.zip / EXAMPLES.EXE / EXAM92.C < prev    next >
Text File  |  1991-03-23  |  9KB  |  206 lines

  1.   #include "menu.h"
  2.  
  3.   #define BLACKONWHITE   CREATE_VIDEO_ATTRIBUTE(white,black)
  4.  
  5.  
  6.   int menu_routine();
  7.  
  8.   POPUP_MENU_ENTRY menu_items1[] = {
  9.                                     " Load      F3",1,'L',F3,menu_routine,
  10.                                     " Pick  Alt-F3",2, 'P',ALTF3,menu_routine,
  11.                                     " New"         ,3, 'N',0,menu_routine,
  12.                                     " Save      F2",4, 'S',F2,menu_routine,
  13.                                     " Write to    ",5, 'W',0,menu_routine,
  14.                                     " Directory   ",6, 'D',0,menu_routine,
  15.                                     " Change Dir"  ,7, 'C',0,menu_routine,
  16.                                     " OS shell"    ,8, 'O',0,menu_routine,
  17.                                     " Quit  Alt-X"  ,9,'Q',ALTX,menu_routine,
  18.                                     CWL_NULL,0};
  19.  
  20.  
  21.  
  22.   POPUP_MENU_ENTRY menu_items3[] = {
  23.                         " Run             Ctrl-F9 ",1,'R',CTRLF9,menu_routine,
  24.                         " Program reset   Ctrl-F2 ",2,'P',CTRLF2,menu_routine,
  25.                         " Go to Cursor         F4 ",3,'G',F4,menu_routine,
  26.                         " Trace into           F7 ",4,'T',F7,menu_routine,
  27.                         " Step over            F8 ",5,'S',F8,menu_routine,
  28.                         " User screen      Alt-F5 ",6,'U',ALTF5,menu_routine,
  29.                         CWL_NULL,0};
  30.  
  31.  
  32.   POPUP_MENU_ENTRY menu_items4[] = {
  33.           " Compile to OBJ                   ",1,'C',0,menu_routine,
  34.           " Make EXE file                    ",2,'M',0,menu_routine,
  35.           " Link EXE file                    ",3,'L',0,menu_routine,
  36.           " Build all                        ",4,'B',0,menu_routine,
  37.           " Primary C file:                  ",5,'P',0,menu_routine,
  38.           " Get info                         ",6,'G',0,menu_routine,
  39.             CWL_NULL,0};
  40.  
  41.  
  42.   POPUP_MENU_ENTRY menu_items5[] = {
  43.           " Project Name                     ",1,'P',0,menu_routine,
  44.           " Break make on                    ",2,'B',0,menu_routine,
  45.           " Auto dependencies                ",3,'A',0,menu_routine,
  46.           " Clear project                    ",4,'C',0,menu_routine,
  47.           " Remove messages                  ",5,'R',0,menu_routine,
  48.             CWL_NULL,0};
  49.  
  50.  
  51.   POPUP_MENU_ENTRY menu_items6[] = {
  52.           " Compiler          ",1,'C',0,menu_routine,
  53.           " Linker            ",2,'L',0,menu_routine,
  54.           " Environment       ",3,'E',0,menu_routine,
  55.           " Directories       ",4,'D',0,menu_routine,
  56.           " Arguments         ",5,'A',0,menu_routine,
  57.           " Save Options      ",6,'S',0,menu_routine,
  58.           " Retrieve options  ",7,'R',0,menu_routine,
  59.           CWL_NULL,0};
  60.  
  61.  
  62.   POPUP_MENU_ENTRY menu_items7[] = {
  63.           " Evaluate    Ctrl-F4           ",1,'E',CTRLF4,menu_routine,
  64.           " Call Stack  Ctrl-F3           ",2,'C',CTRLF3,menu_routine,
  65.           " Find Function                 ",3,'F',0,menu_routine,
  66.           " Refresh display               ",4,'R',0,menu_routine,
  67.           " Display swapping     Smart    ",5,'D',0,menu_routine,
  68.           " Source debugging              ",6,'S',0,menu_routine,
  69.           CWL_NULL,0};
  70.  
  71.  
  72.   POPUP_MENU_ENTRY menu_items8[] = {
  73.           " Add watch           Ctrl-F7 ",1,'A',CTRLF7,menu_routine,
  74.           " Delete watch                ",2,'D',0,menu_routine,
  75.           " Edit Watch                  ",3,'E',0,menu_routine,
  76.           " Remove all watches          ",4,'R',0,menu_routine,
  77.           " Toggle breakpoint   Ctrl-F8 ",6,'T',CTRLF8,menu_routine,
  78.           " Clear all breakpoints       ",7,'C',0,menu_routine,
  79.           " View next breakpoint        ",8,'V',0,menu_routine,
  80.           CWL_NULL,0};
  81.  
  82.  
  83.   BAR_MENU_ENTRY bar_items[] = {
  84.               "File",1,4,'F',0,NULLFN,
  85.         "Edit",1,10,'E',0,menu_routine,
  86.               "Run",1,17,'R',0,NULLFN,
  87.               "Compile",1,23,'C',0,NULLFN,
  88.               "Project",1,33,'P',0,NULLFN,
  89.               "Options", 1,43,'O',0,NULLFN,
  90.               "Debug",1,53,'D',0,NULLFN,
  91.               "Break/watch",1,61,'B',0,NULLFN,
  92.                                     CWL_NULL};
  93.   POPUP_MENU_ENTRY  *pentry[] = {menu_items1, POPUP_NULL_ENTRY, menu_items3,
  94.                                 menu_items4, menu_items5, menu_items6,
  95.                                 menu_items7, menu_items8};
  96.  
  97.   unsigned menu_colors[5];    /* Menu colors */
  98.   BAR_MENU_PTR bar;           /* Pointer to bar menu */
  99.   POPUP_MENU_PTR popups[8];   /* Array of pointers to popup menus */
  100.   PULLDOWN_MENU_PTR pull;     /* Pointer to pulldown menu */
  101.  
  102.   WPOINTER my_open();         /* Pointer to custom bar window open function */
  103.   int popuprank[] = {1,1,1,1,1,1,1,1};  /* Ranks of popup windows */
  104.   int popupstart[] = {1,1,1,1,1,1,1,1}; /* Starting option for each popup
  105.                                            menu */
  106.   int height[] = {9,0,6,6,5,7,6,8};     /* height of each window */
  107.  
  108.   WPOINTER pw;  /* Misc. windows, not part of menu
  109.                                             system */
  110.  
  111.   char *line =
  112.           "─────────────────────────────"; /* Horizontal line */
  113.  
  114.  
  115.   main()
  116.   {
  117.     int i;
  118.     WindowInitializeSystem();
  119.     WindowSaveInitial(0);
  120.     pw = WindowInitialize(BORDER,5,10,70,5,BLACKONWHITE,BLACKONWHITE,
  121.                           SINGLEBOX);
  122.     WindowOpen(pw);
  123.    /* define colors */
  124.     menu_colors[0] = CREATE_VIDEO_ATTRIBUTE(white,black);
  125.     menu_colors[1] = CREATE_VIDEO_ATTRIBUTE(white,black);
  126.     menu_colors[2] = CREATE_VIDEO_ATTRIBUTE(white,blue);
  127.     menu_colors[3] = CREATE_VIDEO_ATTRIBUTE(cyan,black);
  128.     menu_colors[4] = CREATE_VIDEO_ATTRIBUTE(white,black);
  129.  
  130.     bar = BarCreateMenu(bar_items,  /* Array of BAR_MENU_ENTRY's   */
  131.                         menu_colors,/* Pointer to menu colors      */
  132.                         6,          /* Row to open bar menu window */
  133.                         1,          /* Column to open bar menu window */
  134.                         my_open);   /* Customized window open function */
  135.  
  136.                   /* Now set bar options  */
  137.  
  138.     BarSetOptions(bar,BARWRAP | BARSTATIC,1);   /* Wrap highlight bar */
  139.  
  140.                  /* Now loop to create all popup menus
  141.           Be careful and asign NULL to the second popup menu */
  142.  
  143.  
  144.     for (i=0; i<8; i++)       /* Loop for all popup menus */
  145.     {
  146.       if (pentry[i] != POPUP_NULL_ENTRY)  /* Skip over NULL popup entry */
  147.       {
  148.         popups[i] =
  149.         PopupCreateMenu(pentry[i],   /* Array of POPUP_MENU_ENTRY's */
  150.                         menu_colors, /* Array of menu colors,        */
  151.  
  152.                           /* The next two arguments will later be ignored */
  153.                           1,           /* Row to open popup window on */
  154.                           1,           /* Column to open popup */
  155.                           height[i], /* height of the popup window   */
  156.                                            /* No custom window open
  157.                                               functions */
  158.                           WNULLFN,
  159.                           VWNULLFN);
  160.  
  161.  
  162.               /* Now set the popup menu options */
  163.         PopupSetOptions(popups[i],POPUPWRAP | POPUPSTATIC,1);   /* Wrap the
  164.                                                                    window */
  165.       }
  166.       else
  167.         popups[i] = (POPUP_MENU_PTR)0;  /* Make this a null POPUP_MENU_PTR */
  168.     }  /* end for (i=0 ... */
  169.     VirtualWriteString(popups[7]->w->vwptr,line,5,1);   /* Draw horizontal line
  170.                                                            in virtual window */
  171.  
  172.     PopupMakeEntryUnavailable(popups[6],2);   /* hide 2nd and 3rd entries in */
  173.     PopupMakeEntryUnavailable(popups[6],3);   /* popups[6]  */
  174.     PopupSetOptions(popups[6],POPUPOVERRIDE,1);
  175.  
  176.     pull = PulldownCreateMenu(popups,bar,1);
  177.     PulldownSelectMenu(pull,1,1,popuprank,popupstart,1);
  178.     PulldownMenuFree(pull);
  179.   }
  180.  
  181.   int menu_routine(PULLDOWN_MENU_PTR p, BAR_MENU_PTR b, POPUP_MENU_PTR pop,
  182.                    int hs, int vs)
  183.   {
  184.     int ch;
  185.     WindowClear(pw);
  186.     WindowPrintf(pw,
  187.              "You have selected bar option %d   vertical option %d\n",hs,vs);
  188.     WindowWriteCenterString(pw,"Press Escape to Quit",3);
  189.     WindowWriteCenterString(pw,"Press any other key to continue...",4);
  190.     WindowDisplay(pw,1,NOEFFECT);
  191.     ch = GET_KEY();
  192.     WindowHide(pw,NOEFFET);
  193.     if (ch == ESC)
  194.       return PULLDOWN_EXIT;
  195.     return PULLDOWN_CONTINUE;
  196.   }
  197.  
  198.  
  199.   WPOINTER my_open()          /* Custom window open function for bar menu */
  200.   {
  201.     WPOINTER w;
  202.     w = WindowInitialize(NOBORDER,1,1,80,1,BLACKONWHITE,BLACKONWHITE,"");
  203.     WindowOpen(w);
  204.     return w;
  205.   }
  206.